package com.rub.android.widget

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.rub.android.jetpack.viewmodel.GithubViewModel
import com.rub.android.service.GitHubService
import com.rub.android.service.TagsService
import com.rub.android.service.UserService
import com.rub.android.viewmodel.TagsViewModel
import com.rub.android.viewmodel.UserViewModel

/**
 * https://stackoverflow.com/questions/61338346/not-enough-information-to-infer-type-variable-t
 */
class TagsViewModelFactory(private val repository: TagsService) : ViewModelProvider.NewInstanceFactory()  {

    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return TagsViewModel(repository) as T
    }
}

class UserViewModelFactory(private val repository: UserService) : ViewModelProvider.NewInstanceFactory()  {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return UserViewModel(repository) as T
    }
}



class GitHubViewModelFactory(private val repository: GitHubService) : ViewModelProvider.NewInstanceFactory()  {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return GithubViewModel(repository) as T
    }
}